package com.qf.fanwang.service.impl;

import com.qf.fanwang.dao.UserDao;
import com.qf.fanwang.pojo.User;
import com.qf.fanwang.service.UserService;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.util.List;

public class UserServiceImpl implements UserService {
private UserDao udao;


    @Override
    public List<User> selectAll() {
        try {
            SqlSession sqlSession = new SqlSessionFactoryBuilder().build(Resources.getResourceAsStream("mybatis.xml")).openSession(true);
            udao=sqlSession.getMapper(UserDao.class);
            return udao.selectByPage();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}
